package at.com.vn.chess.entity;

import java.awt.Rectangle;

import at.com.vn.chess.util.Const;

import vn.nnn.shogi.quanco.QuanCo;

/**
 * @author nghilt
 * 2011/11/01
 */
public class H {
	/**
	 * Ten quan co
	 */
	private String oldN;
	private String newN;
	
	
	/**
	 * Toa do cu X
	 */
	private Integer oldX;
	
	/**
	 * Toa do cu Y
	 */
	private Integer oldY;
	
	/**
	 * Toa do moi X
	 */
	private Integer newX;
	
	/**
	 * Toa do moi Y
	 */
	private Integer newY;
	
	/**
	 * Mau sac quan vua moi danh xong
	 * 1: Quan den
	 * 0: Quan trang
	 */
	private Integer oldC;
	private Integer newC;
	
	private Integer oldTb;
	private Integer newTb;
	
	private String rId;
	private Integer tId;
	private Integer idx;
	
	public H() {
		oldN = "";
		newN = "";
		oldX = 0;
		oldY = 0;
		newX = 0;
		newY = 0;
		oldC = QuanCo.QUAN_DEN;
		newC = QuanCo.QUAN_DEN;
		oldTb = Const.FALSE;
		newTb = Const.FALSE;
		idx = 0;
		rId = "";
		tId = 0;	
	}
	
	public H( String roomId, int tableId ) {
		this();
		rId = roomId;
		tId = tableId;
	}
	
	public H( int idx, String roomId, int tableId, QuanCo quanCo ) {
		this( quanCo );
		
		this.idx = idx;
		rId = roomId;
		tId = tableId;	
	}
	
	public H( QuanCo quanCo ) {
		this();
		newN = quanCo.getClass().getSimpleName();
		oldX = quanCo.toaDo.x;
		oldY = quanCo.toaDo.y;
		oldC = quanCo.color;
	}
	
	public H( int idx, QuanCo quanCo, ChessBoardInfo newInfo ) {
		this();
		this.idx = idx;
		rId = newInfo.getRId();
		tId = newInfo.getTId();
		
		oldN = quanCo.getClass().getSimpleName();
		oldC = quanCo.color;
		oldX = quanCo.getX();		
		oldY = quanCo.getY();
		
		newN = newInfo.getName();		
		newX = newInfo.getX();
		newY = newInfo.getY();		
		newC = newInfo.getColor();
		
		if( quanCo.isTuBinh ) {
			oldTb = Const.TRUE;
		}else {
			oldTb = Const.FALSE;
		}
		
		newTb = newInfo.getIsTB();
	}
	

	public String getOldN() {
		return oldN;
	}

	public void setOldN(String oldN) {
		this.oldN = oldN;
	}

	public String getNewN() {
		return newN;
	}

	public void setNewN(String newN) {
		this.newN = newN;
	}

	public Integer getOldC() {
		return oldC;
	}

	public void setOldC(Integer oldC) {
		this.oldC = oldC;
	}

	public Integer getNewC() {
		return newC;
	}

	public void setNewC(Integer newC) {
		this.newC = newC;
	}

	public Integer getOldX() {
		return oldX;
	}

	public void setOldX( Integer oldX ) {
		this.oldX = oldX;
	}

	public Integer getOldY() {
		return oldY;
	}

	public void setOldY( Integer oldY ) {
		this.oldY = oldY;
	}

	public Integer getNewX() {
		return newX;
	}

	public void setNewX( Integer newX ) {
		this.newX = newX;
	}

	public Integer getNewY() {
		return newY;
	}

	public void setNewY( Integer newY ) {
		this.newY = newY;
	}
	
	public String getRId() {
		return rId;
	}

	public void setRId( String rId ) {
		this.rId = rId;
	}

	public Integer getTId() {
		return tId;
	}

	public void setTId( Integer tId ) {
		this.tId = tId;
	}

	public Integer getIdx() {
		return idx;
	}

	public void setIdx( Integer idx ) {
		this.idx = idx;
	}

	public void setOld( Rectangle rect ) {
		oldX = rect.x;		
		oldY = rect.y;
	}
	
	public void setNew( Rectangle rect ) {
		newX = rect.x;		
		newY = rect.y;
	}
	
	public void changeColor() {
		if( oldC == QuanCo.QUAN_DEN ) {
			oldC = QuanCo.QUAN_TRANG;
		}else {
			oldC = QuanCo.QUAN_DEN;
		}
		
		if( newC == QuanCo.QUAN_DEN ) {
			newC = QuanCo.QUAN_TRANG;
		}else {
			newC = QuanCo.QUAN_DEN;
		}
	}

	public Integer getOldTb() {
		return oldTb;
	}

	public void setOldTb( Integer oldTb ) {
		this.oldTb = oldTb;
	}

	public Integer getNewTb() {
		return newTb;
	}

	public void setNewTb( Integer newTb ) {
		this.newTb = newTb;
	}
}
